<template>
  <div id="myEditor"></div>
</template>

<script setup>
import { onMounted, defineEmits } from 'vue'
import E from 'wangeditor'

const emit = defineEmits(['inputChange'])

const props = defineProps({
  content: {
    type: String,
    default: ''
  }
})

onMounted(() => {
  const editor = new E('#myEditor')
  editor.create()
  // 初始值
  props.content && editor.txt.html(props.content)
  editor.config.onchange = function (newHtml) {
  // console.log("change 之后最新的 html", newHtml);
  emit('inputChange', newHtml)
};
})
</script>
